//
//  GRContactHeader.m
//  YC_GRice
//
//  Created by LiuFeng on 2018/7/24.
//  Copyright © 2018年 YeCai. All rights reserved.
//

#import "GRContactHeader.h"

@interface GRContactHeader ()
{
    NSInteger LastIndex;
}
@property (weak, nonatomic) IBOutlet UILabel *relation;

@property (weak, nonatomic) IBOutlet UIButton *relationLeftBtn;
@property (weak, nonatomic) IBOutlet UIButton *relationMiddleBtn;
@property (weak, nonatomic) IBOutlet UIButton *relationLastBtn;

@end

@implementation GRContactHeader

-(void)awakeFromNib {
    [super awakeFromNib];
    self.contentView.backgroundColor     = [UIColor whiteColor];
    LastIndex = 100;
    _relationLeftBtn.layer.borderColor   = [HEXCOLOR(0xdddddd) CGColor];
    _relationMiddleBtn.layer.borderColor = [HEXCOLOR(0xdddddd) CGColor];
    _relationLastBtn.layer.borderColor   = [HEXCOLOR(0xdddddd) CGColor];
}

- (void)contactPersonAtSection:(NSInteger)section {
    switch (section) {
        case 0:{
            _relation.text = @"直系亲属";
            [_relationLeftBtn setTitle:@"父母" forState:UIControlStateNormal];
            [_relationMiddleBtn setTitle:@"配偶" forState:UIControlStateNormal];
            [_relationLastBtn setTitle:@"兄弟姐妹" forState:UIControlStateNormal];
        }
            break;
            
        default:{
            _relation.text = @"重要朋友";
            [_relationLeftBtn setTitle:@"同事" forState:UIControlStateNormal];
            [_relationMiddleBtn setTitle:@"朋友" forState:UIControlStateNormal];
            [_relationLastBtn setTitle:@"同乡" forState:UIControlStateNormal];
        }
            break;
    }
}

- (IBAction)chooseRelation:(UIButton *)sender {
    if (sender.tag != LastIndex) {
        sender.backgroundColor = KGMTHEM_COLOR;
        UIButton *LastBtn = [self viewWithTag:LastIndex];
        LastBtn.backgroundColor = [UIColor whiteColor];
        LastIndex = sender.tag;
        self.type = LastIndex - 100;
    }
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
